package com.cn.designpatterns.ex.concrete.mediator.demo1;

/**
 * @author: zhangyi
 * @date: 2019/1/10 16:55
 * @description:
 */
public class ColleagueMediator extends Mediator {

    private ZYColleague zyColleague;
    private CYColleague cyColleague;

    public void setCyColleague(CYColleague cyColleague) {
        this.cyColleague = cyColleague;
    }

    public void setZyColleague(ZYColleague zyColleague) {
        this.zyColleague = zyColleague;
    }

    @Override
    void send(Message message, Colleague colleague) {
        if(colleague instanceof ZYColleague){
            zyColleague.sendAllColleague(message);
        }else if(colleague instanceof CYColleague){
            cyColleague.sendAllColleague(message);
        }
    }
}
